package service

import (
	__ "base_srv/basic/baseproto"
	"base_srv/handler/dao"
	"context"
)

// PassengerAppAdd 乘客端app应用添加
func (s *Server) PassengerAppAdd(_ context.Context, in *__.PassengerAppAddReq) (*__.PassengerAppAddResp, error) {
	id, err := dao.PassengerAdd(in)
	if err != nil {
		return nil, err
	}
	return &__.PassengerAppAddResp{Id: int64(id)}, nil
}

// PassengerAppList  乘客端app应用列表
func (s *Server) PassengerAppList(_ context.Context, in *__.PassengerAppListReq) (*__.PassengerAppListResp, error) {
	list, err := dao.PassengerAppList()
	if err != nil {
		return nil, err
	}
	return &__.PassengerAppListResp{
		PassengerAppList: list,
	}, nil
}

// PassengerAppUpdate 乘客端app应用更新
func (s *Server) PassengerAppUpdate(_ context.Context, in *__.PassengerAppUpdateReq) (*__.PassengerAppUpdateResp, error) {

	err := dao.PassengerUpdate(in)
	if err != nil {
		return nil, err
	}
	return &__.PassengerAppUpdateResp{Id: in.Id}, nil
}

// 司机端app添加
func (s *Server) DriverAppAdd(_ context.Context, in *__.DriverAppAddReq) (*__.DriverAppAddResp, error) {
	id, err := dao.DriverAppAdd(in)
	if err != nil {
		return nil, err
	}
	return &__.DriverAppAddResp{Id: int64(id)}, nil
}

// 司机端app列表
func (s *Server) DriverAppList(_ context.Context, in *__.DriverAppListReq) (*__.DriverAppListResp, error) {
	list, err := dao.DriverAppList()
	if err != nil {
		return nil, err
	}
	return &__.DriverAppListResp{
		DriverAppList: list,
	}, nil
}

// 司机端app更新
func (s *Server) DriverAppUpdate(_ context.Context, in *__.DriverAppUpdateReq) (*__.DriverAppUpdateResp, error) {
	err := dao.DriverAppUpdate(in)
	if err != nil {
		return nil, err
	}
	return &__.DriverAppUpdateResp{Id: in.Id}, nil
}

// 车机端app添加
func (s *Server) CarAppUpdateAdd(_ context.Context, in *__.CarAppUpdateAddReq) (*__.CarAppUpdateAddResp, error) {
	id, err := dao.CarAppAdd(in)
	if err != nil {
		return nil, err
	}
	return &__.CarAppUpdateAddResp{Id: int64(id)}, nil
}

// 车机端app列表
func (s *Server) CarAppUpdateList(_ context.Context, in *__.CarAppUpdateListReq) (*__.CarAppUpdateListResp, error) {
	list, err := dao.CarAppList()
	if err != nil {
		return nil, err
	}
	return &__.CarAppUpdateListResp{
		CarAppUpdateList: list,
	}, nil
}

// 车机端app更新
func (s *Server) CarAppUpdate(_ context.Context, in *__.CarAppUpdateReq) (*__.CarAppUpdateResp, error) {
	err := dao.CarAppUpdate(in)
	if err != nil {
		return nil, err
	}
	return &__.CarAppUpdateResp{Id: in.Id}, nil
}
